var electron = require('electron') 

var app = electron.app   

var  globalShortcut = electron.globalShortcut

var BrowserWindow = electron.BrowserWindow;

var mainWindow = null ;
app.on('ready',()=>{
    mainWindow = new BrowserWindow({
        width:500,
        height:500,
        webPreferences:{ nodeIntegration:true}
    })

    globalShortcut.register('ctrl+e', () => {
        mainWindow.loadURL('https://www.unisound.com/')
    })

    let isRegister= globalShortcut.isRegistered('ctrl+e')?'Register Success':'Register fail'
    console.log('------->'+isRegister)

    mainWindow.webContents.openDevTools()

    
    mainWindow.loadFile('index.html')

    mainWindow.on('closed',()=>{
        mainWindow = null
    })

})

app.on('will-quit',function(){
    //注销全局快捷键的监听
    console.log('will-quit: 注销全局快捷键的监听')
    globalShortcut.unregister('ctrl+e')
    globalShortcut.unregisterAll()

})
